# 首先 import 必要的模块
import pandas as pd

def inhance():
    allTdata=pd.read_csv("./predate/allTdata.csv",index_col=0)            #导入测试集
    # print(allTdata.shape)

    handoutline=set()
    def handclf(flag, howbig, zhengfu, allTdata, handoutlineset):
        if zhengfu == 1:
            one = set(allTdata[allTdata[flag] > howbig].index)
            handoutlineset = handoutlineset | one
            # print(flag)
            # print(len(handoutlineset))
            allTdata = allTdata.drop(allTdata[allTdata[flag] > howbig].index, axis=0)
            # print(allTdata.shape)
            return handoutlineset, allTdata
        if zhengfu == 0:
            one = set(allTdata[allTdata[flag] < howbig].index)
            handoutlineset = handoutlineset | one
            # print(flag)
            # print(len(handoutlineset))
            allTdata = allTdata.drop(allTdata[allTdata[flag] < howbig].index, axis=0)
            # print(allTdata.shape)
            return handoutlineset, allTdata

    def handclfall(handoutline,allTdata):
        handoutline,allTdata=handclf('c0',0.1,1,allTdata,handoutline)
        handoutline,allTdata=handclf('c14',0.025,1,allTdata,handoutline)
        handoutline,allTdata=handclf('c15',-0.5,0,allTdata,handoutline)
        handoutline,allTdata=handclf('B_ai2_fft_frequency_max',3500,1,allTdata,handoutline)
        return handoutline,allTdata

    handoutline,allTdata=handclfall(handoutline,allTdata)                   #提出了离群点，返回了离群点的索引，和之后的测试集
    # print(len(handoutline))

    result1=pd.read_csv('GBDT_FTRL.csv',index_col=0)

    result1.ix[list(handoutline)]=1                                        #把离群点设置为1

    result1.to_csv('430_01.csv',index_label='idx')